package org.dbpt.performance;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class TimeMeasure extends ContainerItem {

	public TimeMeasure() {
		this((List<DBPTItem>)null);
	}

	public TimeMeasure(List<DBPTItem> children) {
		super(children);
		setMeasureName("time");
	}

	public TimeMeasure(DBPTItem child1, DBPTItem child2, DBPTItem child3) {
		this(new ArrayList<DBPTItem>(Arrays.asList(new DBPTItem[]{child1, child2, child3})));
	}

	public TimeMeasure(DBPTItem child1, DBPTItem child2) {
		this(new ArrayList<DBPTItem>(Arrays.asList(new DBPTItem[]{child1, child2})));
	}

	public TimeMeasure(DBPTItem child) {
		this(new ArrayList<DBPTItem>(Arrays.asList(new DBPTItem[]{child})));
	}

	@Override
	public void doIteration() {
		long t1 = System.currentTimeMillis();
		super.doIteration();
		long t2 = System.currentTimeMillis();
		long t = t2 - t1;
		setMeasureValue(t);
	}
	
}
